package de.wepner.texteditor.command;

import java.awt.event.ActionEvent;

import de.wepner.texteditor.model.EditedFile;
import de.wepner.texteditor.model.EditorData;


/**
 * <p>Creates a new and empty textfile.</p>
 * <p>The file is marked as dirty by default.</p>
 * 
 * @author Richard Wepner
 */
public class NewFileCommand extends Command {
    
    private final EditorData data;
    
    public NewFileCommand(EditorData data) {
        this.data = data;
    }
    
    @Override
    public void actionPerformed(ActionEvent event) {
        EditedFile file = new EditedFile();
        this.data.setEditedFile(file);
        file.setDirty(true);
    }
}
